using Infrastructure.Attribute;
using Infrastructure.Extensions;
using JTZY.Model.Account.Dto;
using JTZY.Model.Account;
using JTZY.Repository;
using JTZY.Service.Account.IAccountService;

namespace JTZY.Service.Account
{
    /// <summary>
    /// 线下收款账号Service业务层处理
    /// </summary>
    [AppService(ServiceType = typeof(IOfflineaccountService), ServiceLifetime = LifeTime.Transient)]
    public class OfflineaccountService : BaseService<Offlineaccount>, IOfflineaccountService
    {
        /// <summary>
        /// 查询线下收款账号列表
        /// </summary>
        /// <param name="parm"></param>
        /// <returns></returns>
        public PagedInfo<OfflineaccountDto> GetList(OfflineaccountQueryDto parm)
        {
            var predicate = QueryExp(parm);

            var response = Queryable()
                .Where(predicate.ToExpression())
                .ToPage<Offlineaccount, OfflineaccountDto>(parm);

            return response;
        }


        /// <summary>
        /// 获取详情
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        public Offlineaccount GetInfo(int Id)
        {
            var response = Queryable()
                .Where(x => x.Id == Id)
                .First();

            return response;
        }

        /// <summary>
        /// 添加线下收款账号
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public Offlineaccount AddOfflineaccount(Offlineaccount model)
        {
            return Insertable(model).ExecuteReturnEntity();
        }

        /// <summary>
        /// 查询导出表达式
        /// </summary>
        /// <param name="parm"></param>
        /// <returns></returns>
        private static Expressionable<Offlineaccount> QueryExp(OfflineaccountQueryDto parm)
        {
            var predicate = Expressionable.Create<Offlineaccount>();

            return predicate;
        }
    }
}